package cn.jhz.learn.blog.test.impl;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.jhz.learn.blog.service.core.open.CategoryService;
import cn.jhz.learn.blog.dao.other.BlogCategoryMapper;
import cn.jhz.learn.blog.po.other.BlogCategory;

@Service("categoryService")
public class CategoryServiceimpl implements CategoryService {
	
	private final BlogCategoryMapper categoryMapper;
	
	@Autowired
	public CategoryServiceimpl(BlogCategoryMapper categoryMapper) {
		this.categoryMapper = categoryMapper;
	}

	@Override
	public Optional<BlogCategory> findCategoryById(Integer categoryId) {
		return null;
	}

	@Override
	public boolean checkCategoryIsExistById(Integer categoryId) {
		BlogCategory category = categoryMapper.selectByPrimaryKey(categoryId);

		if(category == null)
			return false;
		else if(category.getStatus() != (byte) 1)
			return false;
		else
			return true;
	}

}
